package by.vkhalko.asamo.datamodel;

import java.util.Set;
import java.util.TreeSet;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;

@Entity
public class Task extends AbstractEntity {
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;
	@Column
	private String name;
	@ManyToOne(fetch = FetchType.LAZY, targetEntity = Task.class)
	private Task parent;

	@JoinTable(name = "task_2_company", joinColumns = { @JoinColumn(name = "company_id") }, inverseJoinColumns = { @JoinColumn(name = "task_id") })
	@ManyToMany(targetEntity = Company.class, fetch = FetchType.LAZY)
	private Set<Company> company = new TreeSet<Company>();

	@JoinTable(name = "task_2_job_title", joinColumns = { @JoinColumn(name = "job_title_id") }, inverseJoinColumns = { @JoinColumn(name = "task_id") })
	@ManyToMany(targetEntity = JobTitle.class, fetch = FetchType.LAZY)
	private Set<JobTitle> jobTitle = new TreeSet<JobTitle>();

	@Override
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Task getParent() {
		return parent;
	}

	public void setParent(Task parent) {
		this.parent = parent;
	}

}
